package com.twu.biblioteca;

public class Movie {
    private String name;
    private String year;
    private String director;
    private int rating;


    public Movie(String name, String director, String year, int rating) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = rating;
    }

    public Movie(String name, String director, String year) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = 0;
    }

    public String getName() {
        return this.name;
    }

    public String getDirector() {
        return this.director;
    }

    public String getYear() {
        return this.year;
    }

    @Override
    public String toString() {
        String rating = this.rating == 0 ? "unrated" : this.rating + "";
        return name + "      " + director + "    " + year + "    " + rating;
    }

    @Override
    public boolean equals(Object other) {
        if(other == this)
            return true;

        if(!(other instanceof Movie))
            return false;

        Movie otherMovie = (Movie) other;

        return name.equals(otherMovie.name) &&
                director.equals(otherMovie.director) &&
                year.equals(otherMovie.year);

    }
}
